<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
  String _id=request.getParameter("_");
%>
<form id="form_member_update" class="form-horizontal">
  <input type="hidden" name="keyId" id="keyId" value="${keyId}"/>
  <div id="container_member_update"></div>
</form>

<script id="templates_member_update" type="text/x-jsrender">

  <div class="form-group">
    <label class="col-md-3 control-label">成员姓名</label>
    <div class="col-md-7">
      <input type="text" name="name" id="name" value="{{:name}}" class="form-control" readonly>
    </div>
  </div>
  <div class="form-group">
    <label class="col-md-3 control-label">手机号</label>
    <div class="col-md-7">
      <input type="text" name="mobile" id="mobile" value="{{:mobile}}" class="form-control" readonly>
    </div>
  </div>
  <div class="form-group">
    <label class="col-md-3 control-label">邮箱</label>
    <div class="col-md-7">
      <input type="text" name="email" id="email" value="{{:email}}" class="form-control" readonly>
    </div>
  </div>
  <%--
  <div class="bord-top pad-btm"></div>
 --%>

</script>

<script>

  $(function(){

    // 加载数据
    fn_member_update_load();

  });

  // 初始化表单数据
  function fn_member_update_load() {
    var $templates = $.templates('#templates_member_update');
    var $container = $('#container_member_update');
    var keyId =$('#keyId').val();

    var url = '<%=path%>/main/member/read/' + keyId;
    __ajax_get(url, null, function(data) {
      if (data.state == 1) {
        var entity = data.data;

        // 初始化模板
        var html = $templates.render(entity);
        $container.html(html);

        // 表单数据校验
        fn_member_update_validate();

      }
    });
  }

  // 表单数据校验
  function fn_member_update_validate() {
    __init_validate('form_member_update', {
      rules : {
        role : {
          required : false
        }
      },
      messages : {
        role : {
          required : '请选择角色'
        }
      }
    });
  }

  function fn_member_update_save(callback) {
    if (!$('#form_member_update').valid()) {
      return false;
    }
    __confirm_dialog('确定提交么?', null,
            function () {
              __form_save('form_member_update', '<%=path%>/main/member/update', function(data) {
                if(data.state == 1) {

                  callback(data.data);
                } else {
                  callback();
                }
              });
            },
            function () {
              callback();
            }
    );
  }

</script>